import Vue from 'vue'
import VueRouter from 'vue-router'
import Admin from 'views/Admin'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/admin'
  },
  {
    path: '/admin',
    name: 'admin',
    component: Admin,
    rediecct: '/admin/dashboard',
    children: [
      {
        path: '/admin/dashboard',
        name: '仪表盘',
        component: () => import('views/DashBoard'),
        meta: {
          isNav: true
        }
      },
      {
        path: '/admin/artlist',
        name: '文章列表',
        component: () => import('views/ArtList'),
        meta: {
          isNav: true
        }
      },
      {
        path: '/admin/artadd',
        name: 'artadd',
        component: () => import('views/ArtAdd'),
        meta: {
          isNav: false
        }
      },
      {
        path: '/admin/artedit/:id',
        name: 'artedit',
        component: () => import('views/ArtEdit'),
        meta: {
          isNav: false
        }
      },
      {
        path: '/admin/msglist',
        name: '消息中心',
        component: () => import('views/MsgList'),
        meta: {
          isNav: true
        }
      },
      {
        path: '/admin/settings',
        name: '设置',
        component: () => import('views/Settings'),
        meta: {
          isNav: true
        }
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('views/Login')
  },
  {
    path: '*',
    name: 'NotFound',
    component: () => import('views/NotFound')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
